package com.dg11185.nearshop.baidumap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.android.nearshop.R;
import com.dg11185.nearshop.activity.user.LoginActivity;
import com.dg11185.nearshop.app.MyApplication;

/**
 * 商家详情界面跳转到改界面，标记某个商家在地图上的位置
 * 
 * @author：Daibo
 * @time：2014-7-14 下午5:34:48
 */
public class ShopPositionActivity extends BaseShopActivity {

    private TextView shopTitle, shopAddress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initShopOverlay();

        shopTitle = (TextView) this.findViewById(R.id.route_shop_title);
        shopAddress = (TextView) this.findViewById(R.id.route_shop_add);
        shopTitle.setText(shopData.shopTitle);
        shopAddress.setText(shopData.shopAddress);
        if(MyMapLocation.location == null){
            addLocOverlay();
        }
    }

    @Override
    public void setContentView() {
        setContentView(R.layout.map_shop_position);
    }

    /**
     * Button的点击事件，跳转到路线界面
     */
    public void onCheckShopRouteClicked(View v) {
        startActivity(new Intent(this, ChoiceRouteActivity.class));
    }

    /**
     * button点击事件，查看本机地图
     */
    public void onLocalMapRouteClicked(View v) {
        if (MyApplication.getUser() == null) {
            startActivityForResult(new Intent(this, LoginActivity.class), 1);
        }else{
            startActivity(new Intent(this, ErrorFeedbackActivity.class));
        }
    }

    /**
     * Button点击事件，返回上一个页面
     */
    public void onBtnBackClicked(View v) {
        this.finish();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (resultCode) {
        case RESULT_OK:
            startActivity(new Intent(this, ErrorFeedbackActivity.class));
            break;

        default:
            break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
